/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { BaseMatcher } from '../BaseMatcher.js';
import { AnyOf } from '../core/AnyOf.js';
import { IsNull } from '../core/IsNull.js';
/**
 * Matches empty Strings (and null).
 */
export class IsEmptyString extends BaseMatcher {
    constructor() {
        super();
    }
    matches(item) {
        if (item == null) {
            return false;
        }
        return item.length == 0;
    }
    describeTo(description) {
        description.appendText("an empty string");
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string has zero length.
     * For example:
     * <pre>assertThat("", isEmptyString())</pre>
     *
     * @deprecated use is(emptyString()) instead
     * @return The matcher.
     */
    static isEmptyString() {
        return IsEmptyString.emptyString();
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string has zero length.
     * For example:
     * <pre>assertThat("", is(emptyString()))</pre>
     *
     * @return The matcher.
     */
    static emptyString() {
        return IsEmptyString.INSTANCE;
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string is <code>null</code>, or
     * has zero length.
     * For example:
     * <pre>assertThat(((String)null), isEmptyOrNullString())</pre>
     *
     * @deprecated use is(emptyOrNullString()) instead
     * @return The matcher.
     */
    static isEmptyOrNullString() {
        return IsEmptyString.emptyOrNullString();
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string is <code>null</code>, or
     * has zero length.
     * For example:
     * <pre>assertThat(((String)null), is(emptyOrNullString()))</pre>
     *
     * @return The matcher.
     */
    static emptyOrNullString() {
        return IsEmptyString.NULL_OR_EMPTY_INSTANCE;
    }
}
IsEmptyString.INSTANCE = new IsEmptyString();
IsEmptyString.NULL_OR_EMPTY_INSTANCE = AnyOf.anyOfMatches(IsNull.nullValue(), IsEmptyString.INSTANCE);
